


--[[
	表单处理器
	/uri?ab=cd&ef=ghi&jk=lmn
	return form = {
		ab="cd",
		ef="ghi",
		jk="lmn"
	}
	local ab = form["ab"]
]]

local req = require("mvc.req");

local form_handler = {
	form = {},
};

--[[
	实例化formhandler
]]
function form_handler:new()
	local o = {};
	setmetatable(o, self);
	self.__index = self;
	self.form = req.get_params();
	return o;
end

--[[
	返回表单name=value形式的table
]]
function form_handler:get_form()
	return self.form;
end

--[[
	将请求中的参数复制到一个table对象中
]]
function form_handler:copy_properties(object)
	for i, t in pairs(self.form) do
		object[i] = t;
	end
end

--[[
	根据参数名称获取参数值
]]
function form_handler:get(name)
	return self.form[name];
end

return form_handler;

